<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/classteacher/js/jquery-3.5.0.js"></script>
    <link rel="stylesheet" type="text/css" href="bootstrap/bootstrap.min.css">
    <script src="/classteacher/Vue/Vue.js"></script>
    <script src="/classteacher/Vue/axios.js"></script>
</head>
<style>
    body {
        background-color: rgba(192, 192, 192, 0.3);
    }
</style>
<body>
<div id="app" class="container">
    <div>
        <table class="table table-light table-bordered table-hover">
            <thead>
            <tr>
                <th>ID</th>
                <th>名称</th>
                <th>日期</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            <tr v-for="p in papers">
                <td>{{p.paperId}}</td>
                <td>{{p.paperName}}</td>
                <td>{{p.paperBirth}}</td>
                <td>
                    <button class="btn btn-info" @click="find(p.paperId)"/>
                    查看考试详情
                </td>
            </tr>
            </tbody>

            <tfoot>
            </tfoot>
        </table>
    </div>

</div>
<script>
    //牟强

    let refreshToken = localStorage.getItem("refreshToken");
    let token = localStorage.getItem("token");
    let sid = localStorage.getItem("sid");
    new Vue({
        el: "#app",
        data: {
            papers: []
        },
        methods: {
            find: function (pid) {
                localStorage.setItem("sid", sid);
                localStorage.setItem("pid", pid);
                window.location.href = "view_homework.html";
            }
        },
        mounted() {
            axios.get("findTestPaperBySid/" + sid, {
                headers: {
                    "token": token,
                    "refreshToken": refreshToken
                }
            }).then(res => {
                console.log(res.data.data);
                if (res.data.code == 0) {
                    this.papers = res.data.data;
                    if (res.headers.token != null) {
                        //更新本地token
                        localStorage.setItem("token", res.headers.token);
                    }
                }

            });
        }
    });
</script>

</body>
</html>